package com.jinhongone.pattern.behavior.state.after;

/**
 * @author jinho
 * @className Context
 * @description 环境角色
 * @date 2025/4/16 14:58
 */
public class Context {
    //定义不同电梯状态对应的状态对象
    public final static OpeningState OPENING_STATE = new OpeningState();
    public final static ClosingState CLOSING_STATE = new ClosingState();
    public final static RunningState RUNNING_STATE = new RunningState();
    public final static StoppingState STOPPING_STATE = new StoppingState();

    //当前电梯状态
    private LiftState liftState;

    public void setLiftState(LiftState liftState) {
        //修改电梯状态
        this.liftState = liftState;
        //将当前状态同步到各个状态对象
        this.liftState.setContext(this);
    }

    public void open() {
        this.liftState.open();
    }

    public void close() {
        this.liftState.close();
    }

    public void run() {
        this.liftState.run();
    }

    public void stop() {
        this.liftState.stop();
    }
}
